#ifndef VFS_H
#define VFS_H

#include <Types.h>
#include <Inode.h>
#include <AddressSpace.h>
#include <DataSource.h>
#include <string.h>


struct FName{
	char	fname[16];
	char	*start;
	size_t	size;
};

class SuperBlock{
	FName	*files;
	uint32	f_nr;
	public:
		SuperBlock(FName *fn_s, uint32 nr){
			files = fn_s;
			f_nr = nr;
		}
		Inode * getInode(char *fname){
			uint32 i;
			for(i = 0; i < f_nr; i++){
				if(strcmp(fname, files[i].fname)){
					Inode *ind = new Inode(files[i].start, files[i].size);
					return ind;
				}
			}
			return NULL;
		}
};

class VFS{
	SuperBlock	*sb;
	public:
		List	inodes;
		
		VFS(SuperBlock *s){
			sb = s;
		}
		DataSource * open(char *fname){
			Inode *ind = sb->getInode(fname);
			AddressSpace *as = new AddressSpace(ind);
			DataSource *ds = new DataSource(as);
			return ds;
		}
};

extern VFS *vfs;



#endif /* VFS_H */
